package Utils.Freebase;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

import Utils.LoadingCenter;
import Utils.UI.UIUpdater;
import datatypes.film.Film;
import datatypes.film.FilmBudget;
import datatypes.film.filmGenre;
import datatypes.film.filmGenres;
import datatypes.film.filmRole;
import datatypes.film.Films;
import datatypes.film.filmActor;
import datatypes.film.filmActors;
import datatypes.film.filmDirector;
import datatypes.film.filmDirectors;
import datatypes.film.filmRoles;
import datatypes.film.filmWriter;
import datatypes.film.filmWriters;
import datatypes.tv.tvActor;
import datatypes.tv.tvActors;
import datatypes.tv.tvGenre;
import datatypes.tv.tvGenres;
import datatypes.tv.tvGuestRole;
import datatypes.tv.tvGuestRoles;
import datatypes.tv.tvProgram;
import datatypes.tv.tvProgramCreator;
import datatypes.tv.tvProgramCreators;
import datatypes.tv.tvPrograms;
import datatypes.tv.tvStarringRole;
import datatypes.tv.tvStarringRoles;

/**
 * FB_ParsingUtils handles all FreeBase(FB) parsing functionalities
 * 
 * all public parsing functions are designed so they can be executed
 * independently (using a thread pool for example)
 * 
 * @author Micha
 * 
 */

public class FB_ParsingUtils extends LoadingCenter {

	/* global variables */

	// pairs of (estimated budget mid id, estimated budget content)
	public static Map<String, FilmBudget> budgetMap = null;

	public static Map<String, tvStarringRole> starringRoleMap = null;

	public static Map<String, tvProgramCreator> programCreatorMap = null;

	private static Map<String, tvGenre> tvGenreMap = null;

	// private static Map<String, tvStarringRole> regularCastMap = null;

	public  static Map<String, filmRole> filmRolesMap = null;

	public static Map<String, filmDirector> filmDirectorMap = null;

	public static Map<String, Film> filmRoleFilmMap = null;

	// private static Map<String, filmRole> actorFilmRoleMap = null;

	/**
	 * Initialize parsing utilities
	 */
	public static void init() {
		budgetMap = new TreeMap<String, FilmBudget>();
		starringRoleMap = new TreeMap<String, tvStarringRole>();
		programCreatorMap = new TreeMap<String, tvProgramCreator>();
		tvGenreMap = new TreeMap<String, tvGenre>();
		// regularCastMap = new TreeMap<String, tvStarringRole>();
		filmRolesMap = new TreeMap<String, filmRole>();
		filmDirectorMap = new TreeMap<String, filmDirector>();
		filmRoleFilmMap = new TreeMap<String, Film>();
		// actorFilmRoleMap = new TreeMap<String, filmRole>();
	}

	/**
	 * @param tvActorfilePath
	 *            path to the actor .tsv file
	 * @param limit
	 *            limits the number of actors parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed actors
	 */
	public static tvActors Parse_tv_actor(String tvActorfilePath, int limit) {

		int limitCounter = 0;
		String line = null;
		tvActors tv_actors = new tvActors();

		// tv actor related members
		String actor_id = null;
		String name = null;
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					tvActorfilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				actor_id = parts[1];
				tvActor tv_actor = new tvActor(name, actor_id);
				handleStarringRoles(tv_actor, parts[2]);
				tv_actors.addActor(tv_actor);
				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actors: " + e);
			UIUpdater.showErrMsg("error while parsing actors: " + e);
		}

		if (!starringRoleMap.isEmpty()) {
			LoadingCenter.Load_tvStarringRoles();
		}

		return tv_actors;

	}

	/**
	 * @param tvGuestRolesfilePath
	 *            path to the tv guest roles .tsv file
	 * @param limit
	 *            limits the number of guest roles (-1 for unlimited)
	 * 
	 * @return the list of all tvGuestRoles
	 */
	public static tvGuestRoles Parse_tv_guest_roles(
			String tvGuestRolesfilePath, int limit) {

		String line = null;

		// guest role related members
		String name;
		String gr_id;
		String actor;
		String character;
		String episodes_appeared_in;
		String special_performance_type;

		tvGuestRoles tv_guest_roles = new tvGuestRoles();

		String tv_gr_filePath = FBUtils.GetTVFilePathFromID("guest_roles");
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					tv_gr_filePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				gr_id = parts[1];
				actor = parts[2];
				character = parts[3];
				episodes_appeared_in = parts[4];
				special_performance_type = parts[5];

				tv_guest_roles.addGuestRole(new tvGuestRole(name, gr_id, actor,
						character, episodes_appeared_in,
						special_performance_type));
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actor guest roles: " + e);
			UIUpdater.showErrMsg("error while parsing actor guest roles: " + e);
		}
		return tv_guest_roles;

	}

	/**
	 * @param tvStarringRolesfilePath
	 *            path to the tv guest roles .tsv file
	 * @param limit
	 *            limits the number of guest roles (-1 for unlimited)
	 * 
	 * @return the list of all tvGuestRoles
	 */
	public static tvStarringRoles parse_regular_tv_appearance(
			String tvGuestRolesfilePath, int limit) {

		String line = null;

		// guest role related members
		String name;
		String sr_id;
		String actor;
		String character;
		String series;
		String seasons;

		tvStarringRoles tv_starring_roles = new tvStarringRoles();

		String tv_gr_filePath = FBUtils.GetTVFilePathFromID("starring_roles");
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					tv_gr_filePath));
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				sr_id = parts[1];
				actor = parts[2];
				character = parts[3];
				series = parts[4];
				seasons = parts[8];
				tvStarringRole starringRole = new tvStarringRole(name, sr_id,
						actor, character, series, seasons);

				tv_starring_roles.addStarringRole(starringRole);

				if (starringRoleMap.get(sr_id) != null) {
					starringRoleMap.get(sr_id).init(starringRole);
				}

				// if (regularCastMap.get(sr_id) != null) {
				// regularCastMap.get(sr_id).init(starringRole);
				// }

			}

			bi.close();

		} catch (Exception e) {
			System.out
					.println("error while parsing actor starring roles: " + e);
			UIUpdater.showErrMsg("error while parsing actor starring roles: " + e);
		}
		return tv_starring_roles;

	}

	/**
	 * @param tvProgramFilePath
	 *            path to the program .tsv file
	 * @param limit
	 *            limits the number of programs parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed programs
	 */
	public static tvPrograms Parse_tv_programs(String tvProgramFilePath,
			int limit) {
		int limitCounter = 0;
		String line = null;
		tvPrograms tv_programs = new tvPrograms();

		tvProgram tv_program = null;

		// program related members
		String name;
		String id;

		String air_date_of_first_episode;
		String air_date_of_final_episode;
		String number_of_episodes;

		String number_of_seasons;
		String countryOfOrigin = null;
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					tvProgramFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];

				air_date_of_first_episode = parts[3];
				air_date_of_final_episode = parts[4];
				number_of_episodes = parts[5];
				countryOfOrigin = parts[7];

				number_of_seasons = parts[19];

				tv_program = new tvProgram(name, id, air_date_of_first_episode,
						air_date_of_final_episode, number_of_episodes,
						number_of_seasons, countryOfOrigin);
				tv_programs.addProgram(tv_program);

				handleProgramCreator(tv_program, parts[2]);
				handleTvGenre(tv_program, parts[10]);
				handleRegularCast(tv_program, parts[13]);

				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actors: " + e);
			UIUpdater.showErrMsg("error while parsing actors: " + e);
		}

		// if (!programCreatorMap.isEmpty()) {
		// LoadingCenter.Load_tvProgramCreators();
		// }

		// if (!tvGenreMap.isEmpty()) {
		// LoadingCenter.Load_tvGenres();
		// }

		// if (!regularCastMap.isEmpty()) {
		// LoadingCenter.Load_tvStarringRoles();
		// }

		return tv_programs;

	}

	/**
	 * @param tvProgramFilePath
	 *            path to the program creators .tsv file
	 * @param limit
	 *            limits the number of program creators parsed (-1 for
	 *            unlimited)
	 * 
	 * @return the list of all parsed program creators
	 */
	public static tvProgramCreators Parse_tv_program_creators(
			String programCreatorsfilePath, int limit) {
		String line = null;

		// tv program creators related members
		String name;
		String id;
		String programs_created;

		tvProgramCreators program_creators = new tvProgramCreators();
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					programCreatorsfilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				programs_created = parts[2];

				tvProgramCreator tv_creator = new tvProgramCreator(name, id,
						programs_created);

				if (programCreatorMap.get(name) != null) {
					programCreatorMap.get(name).init(tv_creator);
				}

				program_creators.addProgramCreator(tv_creator);

			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actor program creators: "
					+ e);
			
			UIUpdater.showErrMsg("error while parsing actor program creators: "
					+ e);
		}
		return program_creators;
	}

	/**
	 * @param tvGenresFilePath
	 *            path to the program creators .tsv file
	 * @param limit
	 *            limits the number of program creators parsed (-1 for
	 *            unlimited)
	 * 
	 * @return the list of all parsed program creators
	 */
	public static tvGenres Parse_tv_genres(String tvGenresFilePath, int limit) {
		String line = null;

		// tv genre related members
		String name;
		String id;
		String programs;

		tvGenres tv_genres = new tvGenres();

		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					tvGenresFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				programs = parts[2];

				tvGenre tv_genre = new tvGenre(name, id, programs);

				if (tvGenreMap.get(name) != null) {
					tvGenreMap.get(name).init(tv_genre);
				}

				tv_genres.addGenre(tv_genre);

			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actor program creators: "
					+ e);
			
			UIUpdater.showErrMsg("error while parsing actor program creators: "
					+ e);
		}
		return tv_genres;
	}

	/**
	 * @param filmsFilePath
	 *            path to the films .tsv file
	 * @param limit
	 *            limits the number of programs parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed films
	 */
	public static Films Parse_films(String filmsFilePath, int limit) {
		int limitCounter = 0;
		String line = null;
		Films films = new Films();

		Film film = null;

		if (filmsFilePath == null) {
			filmsFilePath = FBUtils.GetFILMFilePathFromID("film");
		}

		// film related members
		String name;
		String id;
		String initial_release_date;

		String written_by;
		String estimated_budget;

		String genre;
		String sequel;
		String prequel;
		String country_of_origin;

		int counter = 0;
		try {
			BufferedReader bi = new BufferedReader(
					new FileReader(filmsFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				initial_release_date = parts[2];

				written_by = parts[5];
				country_of_origin = parts[12];
				genre = parts[19];
				sequel = parts[22];
				prequel = parts[23];

				film = new Film(name, id, initial_release_date, written_by, "",
						genre, sequel, prequel, country_of_origin);

				// handleFilmRoles(film, parts[13]);

				film.setStarringMids(parts[13]);

				// HandleEstimatedBudget(film, parts[11]);

				// handleDirectors(film, parts[3]);

				// System.out.println(counter++);

				film.setDirectorMids( parts[3]);
				films.addFilm(film);

				// if (filmRoleFilmMap.get(name) != null) {
				// filmRoleFilmMap.get(name).init(film);
				// }

				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing films: " + e);
			
			UIUpdater.showErrMsg("error while parsing films: " + e);
		}

		// if (!budgetMap.isEmpty()) {
		// Parse_dated_money_value(films);
		// }
		//
		// // if (!filmRolesMap.isEmpty()) {
		// // Load_filmRoles();
		// // }
		//
		// // if (!filmDirectorMap.isEmpty()) {
		// // Load_filmDirectors();
		// // }
		//
		// // fix budgets
		// for (Film curr_film : films.getFilms()) {
		//
		// if (curr_film.getFilm_budget() == null) {
		// estimated_budget = "unavailable";
		// } else {
		// estimated_budget = curr_film.getFilm_budget().getBudgetValue();
		// }
		//
		// curr_film.setEstimated_budget(estimated_budget);
		// }

		return films;

	}

	private static void Parse_dated_money_value(Films films) {
		String line = null;

		// Parse_dated_money_value related members
		String id;
		String amount;
		String currency;
		String valid_date;
		String source;

		FilmBudget film_budget = null;

		String dated_money_value_path = FBUtils
				.GetMeasurementUnitFilePath("money_value");

		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					dated_money_value_path), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				id = parts[1];
				valid_date = parts[2];
				amount = parts[3];
				currency = parts[4];
				source = parts[5];

				if (budgetMap.get(id) != null) {
					film_budget = new FilmBudget(amount, currency, valid_date,
							source);

					budgetMap.get(id).init(film_budget);
				}

			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing dated money value : " + e);
			UIUpdater.showErrMsg("error while parsing dated money value : " + e);
		}

	}

	/**
	 * @param filmActorfilePath
	 *            path to the film actor .tsv file
	 * @param limit
	 *            limits the number of actors parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed film actors
	 */
	public static filmActors Parse_film_actors(String filmActorfilePath,
			int limit) {

		int limitCounter = 0;
		String line = null;
		filmActors film_actors = new filmActors();

		// film actor related members
		String actor_id = null;
		String name = null;
		filmActor film_actor = null;
		int counter = 0;

		try {
			
			BufferedReader bi = new BufferedReader(new FileReader(
					filmActorfilePath), 256);
			bi.readLine(); // skip id definition
		 
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}
				
				if(counter++ == 827){
					System.out.println("guys!");
				}
 
				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				actor_id = parts[1];

				film_actor = new filmActor(actor_id, name);
				film_actor.setFilmRoleMids(parts[2]);
				film_actors.addActor(film_actor);
				//System.out.println(counter++);
				// handleActorFilmRoles(film_actor, parts[2]);

				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing film actors : " + e);
			UIUpdater.showErrMsg("error while parsing film actors : " + e);
		}

		// if (!actorFilmRoleMap.isEmpty()) {
		// Load_filmRoles();
		// }

		return film_actors;

	}

	/**
	 * @param filmActorfilePath
	 *            path to the film directors .tsv file
	 * @param limit
	 *            limits the number of directors parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed film directors
	 */
	public static filmDirectors Parse_film_directors(
			String filmDirectosFilePath, int limit) {

		int limitCounter = 0;
		String line = null;
		filmDirectors film_directors = new filmDirectors();

		// film actor related members
		String id = null;
		String name = null;
		String films = null;
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					filmDirectosFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				films = parts[2];

				filmDirector film_director = new filmDirector(name, id, films);
			 
				film_directors.addDirector(film_director);

//				if (filmDirectorMap.get(name) != null) {
//					filmDirectorMap.get(name).init(film_director);
//				}

				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing film directors : " + e);
			UIUpdater.showErrMsg("error while parsing film directors : " + e);
		}

		return film_directors;

	}

	/**
	 * @param filmWritersFilePath
	 *            path to the film writers .tsv file
	 * @param limit
	 *            limits the number of writers parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed film writers
	 */
	public static filmWriters Parse_film_writers(String filmWritersFilePath,
			int limit) {

		int limitCounter = 0;
		String line = null;
		filmWriters film_writers = new filmWriters();

		// film actor related members
		String id = null;
		String name = null;
		String films = null;
		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					filmWritersFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {
				if (limitCounter == limit) {
					break;
				}

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				films = parts[2];

				film_writers.addWriter(new filmWriter(name, id, films));

				limitCounter++;
			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing film writers : " + e);
			UIUpdater.showErrMsg("error while parsing film writers : " + e);
		}

		return film_writers;

	}

	/**
	 * @param filmRolesFilePath
	 *            path to the film roles .tsv file
	 * @param limit
	 *            limits the number of roles parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed film roles
	 */
	public static filmRoles Parse_film_roles(String filmRolesFilePath, int limit) {
		String line = null;

		// film role related members
		String id;

		String character;

		filmRoles film_roles = new filmRoles();
		int counter = 0;

		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					filmRolesFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				id = parts[1];

				character = parts[5];

				filmRole film_role = new filmRole(id, character);
				film_roles.addFilmRole(film_role);

				//System.out.println(counter++);
				// if (actorFilmRoleMap.get(id) != null) {
				// actorFilmRoleMap.get(id).init(film_role);
				// }

				// System.out.println(counter++);
				// if (filmRolesMap.get(id) != null) {
				// filmRolesMap.get(id).init(film_role);
				// }

			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actor film roles: " + e);
			UIUpdater.showErrMsg("error while parsing actor film roles: " + e);
		}

		return film_roles;
	}

	/**
	 * @param tvGenresFilePath
	 *            path to the film genres .tsv file
	 * @param limit
	 *            limits the number of film genres parsed (-1 for unlimited)
	 * 
	 * @return the list of all parsed film genres
	 */
	public static filmGenres Parse_film_genres(String filmGenresFilePath,
			int limit) {
		String line = null;

		// films genre related members
		String name;
		String id;
		String films;

		filmGenres film_genres = new filmGenres();

		try {
			BufferedReader bi = new BufferedReader(new FileReader(
					filmGenresFilePath), 256);
			bi.readLine(); // skip id definition
			while ((line = bi.readLine()) != null) {

				String[] parts = line.split(FBUtils.FB_seperator, -1);

				name = parts[0];
				id = parts[1];
				films = parts[2];

				film_genres.addGenre(new filmGenre(name, id, films));

			}

			bi.close();

		} catch (Exception e) {
			System.out.println("error while parsing actor program creators: "
					+ e);
			
			UIUpdater.showErrMsg("error while parsing actor program creators: "
					+ e);
		}
		return film_genres;
	}

	/* all forward reference handling */

	private static void HandleEstimatedBudget(Film film, String budgetMid) {
		if (budgetMid.length() == 0)
			return;

		FilmBudget film_budget = new FilmBudget();
		film.setFilm_budget(film_budget);
		budgetMap.put(budgetMid, film_budget);

	}

	private static void handleStarringRoles(tvActor tv_actor,
			String starringRoleMid) {
		if (starringRoleMid.length() == 0)
			return;

		String[] mids = starringRoleMid.split(",");

		for (String srMid : mids) {
			tvStarringRole tvStarringRole = new tvStarringRole();
			tv_actor.addStarringRole(tvStarringRole);
			starringRoleMap.put(srMid, tvStarringRole);
		}

	}

	private static void handleTvGenre(tvProgram tv_program, String genreMids) {
		if (genreMids.length() == 0)
			return;

		String[] mids = genreMids.split(",");

		for (String genreMid : mids) {
			tvGenre tv_genre = new tvGenre();
			tv_program.addGenre(tv_genre);
			tvGenreMap.put(genreMid, tv_genre);
		}
	}

	private static void handleProgramCreator(tvProgram tv_program,
			String creatorMids) {
		if (creatorMids.length() == 0)
			return;

		String[] mids = creatorMids.split(",");

		for (String creatorMid : mids) {
			tvProgramCreator tv_program_creator = new tvProgramCreator();
			tv_program.addProgramCreator(tv_program_creator);
			programCreatorMap.put(creatorMid, tv_program_creator);
		}
	}

	private static void handleRegularCast(tvProgram tv_program, String castMids) {
		if (castMids.length() == 0)
			return;

		String[] mids = castMids.split(",");

		for (String castMid : mids) {
			tvStarringRole castRole = new tvStarringRole();
			tv_program.addStarringRoleToCast(castRole);
			starringRoleMap.put(castMid, castRole);
		}
	}

	private static void handleFilmRoles(Film film, String roleMid) {
		if (roleMid.length() == 0)
			return;

		String[] mids = roleMid.split(",");

		for (String role_mid : mids) {
			filmRole film_role = new filmRole();
			// film.addFilmRole(film_role);

			filmRolesMap.put(role_mid, film_role);
		}
	}

	private static void handleDirectors(Film film, String directorMids) {
//		if (directorMids.length() == 0)
//			return;
//
//		String[] mids = directorMids.split(",");
//
//		for (String director_mid : mids) {
//			filmDirector film_director = new filmDirector();
//			film.addDirector(film_director);
//
//			filmDirectorMap.put(director_mid, film_director);
//		}
	}

	private static void handleActorFilmRoles(filmActor film_actor,
			String filmRolesMids) {
		if (filmRolesMids.length() == 0)
			return;

		String[] mids = filmRolesMids.split(",");

		for (String filmRoleMid : mids) {
			filmRole film_role = new filmRole();
			// film_actor.addFilmRole(film_role);

			filmRolesMap.put(filmRoleMid, film_role);
		}
	}

}
